<?php
function VN_unaccent($item)
{
  static $search, $replace;
  $trans=array(               'á'=>'a','à'=>'a','ả'=>'a','ã'=>'a','ạ'=>'a', 
                    'ă'=>'a', 'ắ'=>'a','ằ'=>'a','ẳ'=>'a','ẵ'=>'a','ặ'=>'a',         
                    'â'=>'a', 'ấ'=>'a','ầ'=>'a','ẩ'=>'a','ẫ'=>'a','ậ'=>'a',         
                              'Á'=>'A','À'=>'A','Ả'=>'A','Ã'=>'A','Ạ'=>'A', 
                    'Ă'=>'A', 'Ắ'=>'A','Ằ'=>'A','Ẳ'=>'A','Ẵ'=>'A','Ặ'=>'A',         
                    'Â'=>'A', 'Ấ'=>'A','Ầ'=>'A','Ẩ'=>'A','Ẫ'=>'A','Ậ'=>'A',
                              'đ'=>'d','Đ'=>'D',
                              'é'=>'e','è'=>'e','ẻ'=>'e','ẽ'=>'e','ẹ'=>'e',
                    'ê'=>'e', 'ế'=>'e','ề'=>'e','ể'=>'e','ễ'=>'e','ệ'=>'e',
                              'É'=>'E','È'=>'E','Ẻ'=>'E','Ẽ'=>'E','Ẹ'=>'E', 
                    'Ê'=>'E', 'Ế'=>'E','Ề'=>'E','Ể'=>'E','Ễ'=>'E','Ệ'=>'E',
                              'í'=>'i','ì'=>'i','ỉ'=>'i','ĩ'=>'i','ị'=>'i', 
                              'Í'=>'I','ì'=>'I','Ỉ'=>'I','ĩ'=>'I','ị'=>'I', 
                              'ó'=>'o','ò'=>'o','ỏ'=>'o','õ'=>'o','ọ'=>'o', 
                    'ô'=>'o', 'ố'=>'o','ồ'=>'o','ổ'=>'o','ỗ'=>'o','ộ'=>'o',         
                    'ơ'=>'o', 'ớ'=>'o','ờ'=>'o','ở'=>'o','ỡ'=>'o','ợ'=>'o',         
                              'Ó'=>'O','Ò'=>'O','Ỏ'=>'O','Õ'=>'O','Ọ'=>'O', 
                    'Ô'=>'O', 'Ố'=>'O','Ồ'=>'O','Ổ'=>'O','Ỗ'=>'O','Ộ'=>'O', 
                    'Ơ'=>'O', 'Ớ'=>'O','Ờ'=>'O','Ở'=>'O','Ỡ'=>'O','Ợ'=>'O',         
                              'ú'=>'u','ù'=>'u','ủ'=>'u','ũ'=>'u','ụ'=>'u', 
                    'ư'=>'u', 'ứ'=>'u','ừ'=>'u','ử'=>'u','ữ'=>'u','ự'=>'u', 
                              'Ú'=>'U','Ù'=>'U','Ủ'=>'U','Ũ'=>'U','Ụ'=>'U', 
                    'Ư'=>'U', 'Ứ'=>'U','Ừ'=>'U','Ử'=>'U','Ữ'=>'U','Ự'=>'U', 
                              'ý'=>'y','ỳ'=>'y','ỷ'=>'y','ỹ'=>'y','ỵ'=>'y', 
                              'Ý'=>'Y','Ỳ'=>'Y','Ỷ'=>'Y','Ỹ'=>'Y','Ỵ'=>'Y' );
  if (!$search)
  {
    $search = $replace = array(); // Get the HTML entities table into an array
    //$trans = get_html_translation_table(HTML_ENTITIES); // Go through the entity mappings one-by-one
    //print_r($trans);
    foreach ($trans as $literal => $entity)
    { // Make sure we dont process any other characters // such as fractions, quotes etc:
      if (ord($literal) >= 192)
      { // Get the accented form of the letter
        $search[] = $literal; // Get e.g. E from the string ɒ $replace[] = $entity1;
        $replace[]= $entity;
      }
    }
  }
  return str_replace($search, $replace, $item);
}
?>

